<?php
/*
Template Name: Blog
*/

get_header();

$layout=ThemexCore::getOption('blog_layout','right');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$date_format=ThemexCore::getOption('date_format','m/d/Y');

if(isset($post->post_type) && $post->post_type=='page') {
	query_posts(array(
		'post_type' => 'post',
		'paged' => $paged,
	));
}

if($layout=='left') {
?>
<div class="column fourcol">
<?php get_sidebar(); ?>
</div>
<div class="column eightcol last">
<?php } else if($layout=='right') { ?>
<div class="column eightcol">
<?php } else { ?>
<div class="fullwidth-block">
<?php } ?>
	<div class="blog-listing">
	<?php 
	if (have_posts()) {
		while ( have_posts() ) {
			the_post();	
			?>
			<div <?php post_class('post'); ?>>
				<?php if(has_post_thumbnail()) { ?>
				<div class="column fivecol post-featured-image">
					<div class="featured-image">
						<a href="<?php the_permalink(); ?>"><img src="<?php echo themex_thumbnail($post->ID,460); ?>" class="fullwidth" alt="<?php the_title(); ?>" /></a>
					</div>
				</div>
				<div class="column sevencol last">
				<?php } else { ?>
				<div class="fullwidth-block">
				<?php } ?>
					<div class="post-content">
						<div class="block-title"><h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1></div>
						<?php the_excerpt(); ?>
						<div class="post-meta">
							<a href="<?php the_permalink(); ?>" class="button small"><span><?php _e('Read More','midway'); ?></span></a>
							<?php if(comments_open()) { ?>
							<div class="post-comment-count"><?php comments_number('0','1','%'); ?></div>
							<?php } ?>
							<div class="post-info"><?php the_time($date_format); ?></div>
							<div class="clear"></div>
						</div>
					</div>
				</div>
				<div class="clear"></div>
			</div>
			<?php
			}
	} else {
	?>
	<h3><?php _e('No posts found. Try a different search?','midway'); ?></h3>
	<p><?php _e('Sorry, no posts matched your search. Try again with some different keywords.','midway'); ?></p><br />
	<?php }	?>
	</div><!-- items list -->
	<?php 
	themex_pagination(); 
	wp_reset_query(); 
	?>
</div>
<?php if($layout=='right') { ?>
<div class="column fourcol last">
<?php get_sidebar(); ?>
</div>
<?php } ?>
<?php get_footer(); ?>